package cn.wsxiot.jxl;

import java.io.File;
import java.io.IOException;

import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

public class Addition {
	/**
	 *向.xls文件中追加数据
	 * 要先创建文件，即运行cn.wsxiot.jxldemo类
	 * @param args
	 */

	public static void main(String[] args) {
		try {
			File file = new File("jxl_test.xls");
			//获取工作薄
			Workbook wb=Workbook.getWorkbook(file);
			//有已知工作薄创建可写工作薄
			WritableWorkbook wwb=Workbook.createWorkbook(file, wb);
			//获取一个可写sheet
			WritableSheet sh=wwb.getSheet(0);
			int row=sh.getRows();
			Label label=null;
			label=new Label(0,row,"a"+row);
			sh.addCell(label);
			label=new Label(1,row,"user"+row);
			sh.addCell(label);
			label=new Label(2,row,"男");
			sh.addCell(label);
			wwb.write();
			wwb.close();
			wb.close();



		} catch (RowsExceededException e) {
			e.printStackTrace();
		} catch (BiffException e) {
			e.printStackTrace();
		} catch (IndexOutOfBoundsException e) {
			e.printStackTrace();
		} catch (WriteException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
